package com.xstablet.fragment;

import android.graphics.Bitmap;

import com.google.gson.Gson;
import com.lib.bean.ConfigBean;
import com.lib.fastkit.db.shared_prefrences.SharedPreferenceManager;
import com.lib.fastkit.utils.log.LogUtil;
import com.lib.fastkit.utils.share.tool.StringUtil;
import com.lib.fastkit.views.dialog.http.DialogUtils;
import com.lib.ui.fragment.BaseWebFragment;
import com.module_live.activity.CoachStudyLivingActivity;
import com.tencent.smtt.sdk.WebView;
import com.xstablet.R;

public class TabletResourceFragment extends BaseWebFragment {

    public String tabletResUrl = "";
    DialogUtils dialogUtils;
    private ConfigBean configBean;

    @Override
    protected void myOnPageStarted(WebView webView, String s, Bitmap bitmap) {

        dialogUtils.showNormalDialog(getActivity(), "页面加载中......");
    }

    @Override
    protected void myShouldOverrideUrlLoading(WebView webView, String url) {

    }

    @Override
    protected void myOnPageFinished(WebView webView, String s) {

        dialogUtils.dismiss();
    }

    @Override
    protected void onCreateView(WebView webView) {

        dialogUtils = new DialogUtils();

        String json = SharedPreferenceManager.getInstance(getContext()).getUserCache().getConfigJson();
        configBean = new Gson().fromJson(json, ConfigBean.class);
        if (configBean != null) {
            if (StringUtil.isNotEmpty(configBean.getObj().getFamous_teacher_resources_flat(), true)) {

                tabletResUrl = configBean.getObj().getFamous_teacher_resources_flat();

                LogUtil.e("平板名师资源的地址为：" + tabletResUrl);
//        luckyWebview.loadUrl(luckyUrl);
                webView.loadUrl(tabletResUrl);

            }
        }
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_tablet_res;
    }
}
